Skip to content

Replace click LazyFile with a custom type - #716

Merged
sirosen merged 3 commits into
python-jsonschema:mainfrom
sirosen:click-85-compat
Sep 19, 2026
Merged

sirosen merged 3 commits into
python-jsonschema:mainfrom
sirosen:click-85-compat

Conversation

@sirosen

@sirosen sirosen commented Sep 18, 2026

Copy link
Copy Markdown
Member

Heavily inspired by looking at click.utils._LazyFile to see how it
behaves, create a "binary input" type, which acts as a BinaryIO and
otherwise does relatively little. The param type which wraps it is
responsible for attaching it appropriately to the click Context.

@sirosen
sirosen force-pushed the click-85-compat branch 2 times, most recently from 46eda0b to d8562be Compare September 18, 2026 23:58
sirosen and others added 2 commits September 18, 2026 19:08
Heavily inspired by looking at click.utils._LazyFile to see how it
behaves, create a "binary input" type, which acts as a BinaryIO and
otherwise does relatively little. The param type which wraps it is
responsible for attaching it appropriately to the click Context.
This may be a matter of `click-type-test` being out of sync with the
latest `click` release, but it flags these as `bool | None` unless
explicit defaults are set.

Co-authored-by: Edgar Ramírez Mondragón <16805946+edgarrmondragon@users.noreply.github.com>
- Rename the open handle property to an `open()` method, to ensure that
  it has an `open()` method -- though not part of the target interface,
  this is a common expectation around handling binary streams

- Use ABC `register()` to make sure that the class passes isinstance()
  checks even though it does not subclass/inherit
@sirosen
sirosen merged commit ccae8ff into python-jsonschema:main Sep 19, 2026
25 checks passed
@sirosen
sirosen deleted the click-85-compat branch September 19, 2026 03:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant